def power(base, exp: int):
    """
    计算 base 的 exp 次幂
    :param base:
    :param exp:
    :return:
    """
    if base != 0:
        if exp > 0:
            return power(base, exp - 1) * base
        elif exp < 0:
            return power(base, exp + 1) * (1 / base)
        else:
            return 1

    else:
        return 0


if __name__ == '__main__':
    base = 2
    exp = -2
    print(power(base, exp))
